package com.abe.libcore.base.screen.j;

import android.util.DisplayMetrics;

import androidx.fragment.app.Fragment;

import com.abe.libcore.utils.CommonUtils;

public abstract class BJScreenFragment extends Fragment {
    //是否需要自适应布局
    public abstract Boolean isAutoZoom();

    //是否正常设置标准宽度
    private Boolean isScreenSetNormal = false;

    //获取标准宽度
    public int getStandardW() {
        Integer designWidth = (Integer) CommonUtils.INSTANCE.getMetaData(getContext(), "designWidth", 0);
        isScreenSetNormal = designWidth != null;
        return isScreenSetNormal ? designWidth : 0;
    }

    //获取缩放比例
    public Float getScale() {
        DisplayMetrics displayMetrics = getResources().getDisplayMetrics();
        int width = displayMetrics.widthPixels;
        return (isAutoZoom() && isScreenSetNormal) ? ((float) width / (float) getStandardW()) : 1.0F;
    }
}